package com.zt.chatgpt.repository;

import com.zt.chatgpt.auth.repository.IAuthRepository;
import com.zt.chatgpt.redis.IRedisService;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author: zt
 * @Description: 微信验证码存储服务
 * @create: 2024-05-24 21:04
 */

@Repository
public class AuthRepository implements IAuthRepository {

    private static final String KEY = "WEIXIN_CODE";

    @Resource
    private IRedisService redisService;

    @Override
    public String getCodeByUserOpenId(String code) {
        return redisService.getValue(KEY + "_" + code);
    }

    @Override
    public void removeCodeByUserOpenId(String openId, String code) {
        redisService.remove(KEY + "_" + code);
        redisService.remove(KEY + "_" + openId);
    }
}
